package com.flainsky.nirvanaplayer.views;

import com.flainsky.nirvanaplayer.R;
import android.content.Context;
import android.graphics.Bitmap;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.RatingBar;
import android.widget.RelativeLayout;
import android.widget.ImageView;
import android.widget.TextView;

public class MovieInfoRelativeLayout extends RelativeLayout {

	ImageView iv;
	TextView tv;
	RatingBar rb;

	public MovieInfoRelativeLayout(Context context, AttributeSet attrs) {
		super(context, attrs);
		// TODO Auto-generated constructor stub
		LayoutInflater mInflater = LayoutInflater.from(context);
		View myView = mInflater.inflate(R.layout.movie_info_item, this);
		iv = (ImageView)myView.findViewById(R.id.image);
		tv = (TextView)myView.findViewById(R.id.title);
		rb = (RatingBar)myView.findViewById(R.id.rb);
	}
	
	public void setImage(Bitmap bmp)
	{
		if(bmp==null)return;
		iv.setImageBitmap(bmp);
	}
	public void setImageResource(int resId)
	{
		iv.setImageResource(resId);
	}
	
	public void setTitle(String title)
	{
		if(title==null)return;
		tv.setText(title);
	}
	
	public void setRb(float value)
	{
		if(value>5f)
		{
			value = 5f;
		}
		if(value<0f)
		{
			value = 0f;
		}
		rb.setRating(value);
	}
	
	public ImageView getImageView()
	{
		return iv;
	}
}
